<?php

namespace IDock\Printer\NonCar;

use IDock\IDock\IDockEnums;
use IDock\Printer\BasePrinter;
use IDock\Visitor\NonCar\NonCarProductVisitor;

/**
 * 询价结果
 */
class NonCarUnderwritingPrinter extends BasePrinter
{
    /**
     * 投保状态
     * @var IDockEnums::nonCarStatus $statusCode
     */
    public $statusCode = 'success';

    /**
     * 核保提示
     * @var string $message
     */
    public $messageTip = '';

    /**
     * 总投保单号
     * @var array $nonCarInquiryList
     */
    private $nonCarInquiryList = [];

    /**
     * 添加非车
     * @param NonCarInquirySinglePrinter $nonCarInquirySinglePrinter
     * @return void
     */
    public function nonCarSingleAppend(NonCarInquirySinglePrinter $nonCarInquirySinglePrinter): void
    {
        $this->nonCarInquiryList[] = $nonCarInquirySinglePrinter;
    }

    /**
     * @return array
     */
    public function getNonCarInquiryList(): array
    {
        return $this->nonCarInquiryList;
    }

    public function loadVisitor(array $array){
        /*** @var $visitor NonCarProductVisitor */
        foreach ($array as $visitor) {
            $single = new NonCarInquirySinglePrinter();

            foreach (array_keys(get_class_vars(NonCarInquirySinglePrinter::class)) as $var) {
                if (property_exists(NonCarProductVisitor::class,$var)) {
                    $single->$var = $visitor->$var;
                }
            }

            $this->nonCarInquiryList[] = $single;
        }
    }
}
